package com.baizhi.lucene;

import com.baizhi.entrty.Article;
import org.apache.lucene.search.highlight.InvalidTokenOffsetsException;

import java.io.IOException;
import java.util.List;

/**
 * Created by Administrator on 2019/4/15.
 */
public interface LuceneService {
    /**
     * 批量添加索引  追加
     */
    int addIndexs(List<Article> articles) throws IOException;

    /**
     * 添加一个
     * @param cmfzArticle
     * @return
     */
    boolean addIndexOne(Article cmfzArticle) throws IOException;

    /**
     * 删除全部
     * @return
     */
    boolean deleteAllIndex() throws IOException;

    /**
     * 删除一个
     * @param cmfzArticle
     * @return
     */
    boolean deleteOne(Article cmfzArticle);

    /**
     * 修改
     */
    boolean updateOne(Article cmfzArticle);

    /**
     * 查询
     * @param keyword
     * @return
     */
    List<Article> queryByKeyword(String keyword) throws IOException, InvalidTokenOffsetsException;

    /**
     * 重置索引
     * 先删除 再添加
     * @return
     */
    boolean resetIndexDB();

}
